package com.yunwushanhe.document.mapper;

import com.yunwushanhe.document.entity.File;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 云雾山河
 * @since 2022-10-24
 */
@Mapper
@Repository
public interface FileMapper extends BaseMapper<File> {
        @Select("SELECT * FROM file WHERE file_path = #{filePath} AND file_of_user_number = #{fileOfUserNumber} AND deleted != 1 ORDER BY file_judge DESC,id ASC LIMIT #{start},#{end}")
        List<File> getFilePage(Integer start,Integer end,String filePath,String fileOfUserNumber);

        @Select("SELECT COUNT(*) FROM file WHERE file_path = #{filePath} AND file_of_user_number = #{fileOfUserNumber} AND deleted != 1")   //查询数据总数 返回一个int 类型的数字
        Integer getTotal(String filePath,String fileOfUserNumber);

        @Select("SELECT * FROM file WHERE file_path = #{filePath} AND file_of_user_number = #{fileOfUserNumber} AND file_judge = 1 AND deleted != 1 ORDER BY file_judge DESC,id ASC LIMIT #{start},#{end}")
        List<File> getFilePageTwo(Integer start,Integer end,String filePath,String fileOfUserNumber);

        @Select("SELECT COUNT(*) FROM file WHERE file_path = #{filePath} AND file_of_user_number = #{fileOfUserNumber} AND file_judge = 1 AND deleted != 1")   //查询数据总数 返回一个int 类型的数字
        Integer getTotalTwo(String filePath,String fileOfUserNumber);

        @Select("SELECT * FROM file WHERE filename like #{filename} AND file_of_user_number = #{fileOfUserNumber} AND deleted != 1 ORDER BY file_judge ASC,id ASC LIMIT #{start},#{end}")
        List<File> getFilePageVague(Integer start,Integer end,String filename,String fileOfUserNumber);

        @Select("SELECT COUNT(*) FROM file WHERE filename like #{filename} AND file_of_user_number = #{fileOfUserNumber} AND deleted != 1")   //查询数据总数 返回一个int 类型的数字
        Integer getTotalVague(String filename,String fileOfUserNumber);
}
